import {BACKTOP_DISTENCE} from "@/utils/constant"
import BackTop from "content/backTop/BackTop"
//监听图片加载完
const imgListenerMixin = {
  data() {
    return {
      imgListener: null
    }
  },
  mounted() {
    let newRefresh = this._.debounce(this.$refs.scroll.refresh,100)
    this.imgListener = () => {
      newRefresh()
    }
    this.$bus.$on('imgloaed',this.imgListener)
  }
}
//回到头部
const backTopMixin = {
  data() {
    return {
      isBackTopShow: false,
    }
  },
  comments: {
    BackTop,
  },
 methods: {
    //回到顶部
    backTop() {
      this.$refs.scroll.scrollTo(0, 0, 500)
    },
    showBAckTop(pos) {
      this.isBackTopShow = pos.y < -BACKTOP_DISTENCE
    }
 }
}
export {imgListenerMixin, backTopMixin}
